<template>
  <div class="business">
    <ContentBox title="商户中心" @left="back" :fixed="true" :ostyle="style" titlecolor="black">
      <template slot="oleft"><van-icon color="#000" name="arrow-left"/></template>
    </ContentBox>
    <notice class="not"></notice>
    <div class="content">
      <div class="header">
        <div>店铺总览</div>
        <router-link tag="div" to="/storeDetail" v-if="mer_id <= 0">认证信息</router-link>
      </div>
      <div class="data">
        <div class="store">
          <div class="num">{{saleData.today}}</div>
          <div class="day">今日成交</div>
        </div>
        <div class="store">
          <div class="num">{{saleData.yesterday}}</div>
          <div class="day">昨日成交</div>
        </div>
        <div class="store">
          <div class="num">{{saleData.total}}</div>
          <div class="day">总成交</div>
        </div>
      </div>
    </div>
    <div class="main">
      <div class="detail">
        <div class="title">店铺管理</div>
        <router-link tag="div" to="/shopManage" class="info">
          <div>
            <img :src="$img('shop_manage.png')">
            <span>商品管理</span>
          </div>
          <div>
            <img :src="$img('big_right.png')">
          </div>
        </router-link>
        <router-link tag="div" to="/myOrder" class="info" v-if="mer_id <= 0">
          <div>
            <img :src="$img('order_manage.png')">
            <span>订单管理</span>
          </div>
          <div>
            <img :src="$img('big_right.png')">
          </div>
        </router-link>
        <router-link tag="div" to="/dataStatis" class="info" v-if="mer_id <= 0">
          <div>
            <img :src="$img('data_num.png')">
            <span>数据统计</span>
          </div>
          <div>
            <img :src="$img('big_right.png')">
          </div>
        </router-link>
        <router-link tag="div" to="/ChildAccount" class="info" v-if="mer_id <= 0">
          <div>
            <img :src="$img('childaccount.png')">
            <span>子账户管理</span>
          </div>
          <div>
            <img :src="$img('big_right.png')">
          </div>
        </router-link>
      </div>
      <div class="silde" @click="tab">
        <h3 class="plus">+</h3>
        <h2 class="title">新建<br/>商品</h2>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      style: {
        background: '#ffffff'
      },
      saleData: '',
      mer_id: ''
    }
  },
  methods: {
    back () {
      if (this.$store.state.pl === 'H5') {
        this.$router.go(-1)
      } else if (this.$store.state.pl === 'ANDROID') {
        AndroidJsBridge.finish()
      } else if (this.$store.state.pl === 'IOS') {
        window.iosCallHandler('popVC')
      }
    },
    getSaleData () {
      this.$axios.get('/api/store/index/index').then(res => {
        if (res.status === 200) {
          this.saleData = res.data
        }
      })
    },
    tab () {
      this.$router.push({ name: 'shopManage', params: { type: '1' } })
    }
  },
  created () {
    this.mer_id = this.$store.state.uifo.mer_id
    this.getSaleData()
  }
}
</script>

<style lang="scss" scoped>
@import './index.scss';
</style>
